﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Drawing;
using System.Data;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraPrinting;
using DevExpress.XtraReports.UI;
using System.Collections.Specialized;
using System.Drawing.Printing;
using System.IO;
using ViCode_LeVi.Controls.Logs;
using ViCode_LeVi.Data;
using ViCode_LeVi.Configs;
using ViCode_LeVi.Controls.Charts;
using ViCode_LeVi.Controls.BTBData;
namespace ViCode_LeVi.Controls.Reports
{
    public partial class ReportTemplate : XtraReport
    {
       
        private bool m_bLandscapeOrientation;
        private RootData m_oWorkingProject;
        private string m_sTitle;
        private static bool s_bExportCVS = false;
        private static bool s_bExportHTM = VMConfig.Intance.ExpertMode.ShowHtmlExportOption;
        private static bool s_bExportMHT = false;
        private static bool s_bExportPDF = true;
        private static bool s_bExportRTF = VMConfig.Intance.ExpertMode.ShowRtfExportOption;
        private static bool s_bExportTXT = false;
        private static bool s_bExportXLS = false;
        private static bool s_bShowSendAsMailExportOption = VMConfig.Intance.ExpertMode.ShowSendAsMailExportOption;
        public static Color s_colBlueDark = Color.FromArgb(0x2b, 0x63, 0xb7);
        public static Color s_colTableHeader = s_colTableHeaderGray;
        public static Color s_colTableHeaderBlue = Color.FromArgb(0xdd, 230, 0xf2);
        public static Color s_colTableHeaderGray = Color.FromArgb(0xf3, 0xf3, 0xf3);
        public static int s_iChartHeight = 0x1a9;
        public static int s_iDetailHeight = 0x1bd;
        public static int s_iLandscapeBerichtWidth = 200;
        public static int s_iLandscapePageWidth = 0x3c9;
        public static string s_sBarChartImportance = "Weightings-Diagram";
        public static string s_sBarChartQQS = "Diagrams";
        public static string s_sImpactNet = "Net effect";
        public static string s_sPortfolioChart = "QQS-Portfolio";
        public static string s_sPotentialChart = "Potenzialdiagramm";
        public static string s_sPotentialPortfolioChart = "Potentially Portfolio";
        public static string s_sProfileChart = "QQS-Profildiagramm";

        private DetailBand bandDetail;
        private XRTableCell cellBericht;
        private XRTableCell cellCreator;
        private XRTableCell cellFileName;
        private XRTableCell cellCompany;
        private XRTableCell cellCompanyLbl;
        private XRTableCell cellProject;
        private XRTableCell cellProjectLbl;
        private XRTableCell cellTitel;
        private XRLabel lblDemoVersion;
        private XRLabel lblPeriode;
        private PageFooterBand PageFooter;
        private PageHeaderBand PageHeader;
        private XRPageInfo pageInfoDate;
        private XRPageInfo xrPageInfo3;
        private XRTable xrTable1;
        private XRTable xrTable2;
        private XRTableCell xrTableCell7;
        private XRTableRow xrTableRow1;
        private XRTableRow xrTableRow2;
        private XRTableRow xrTableRow3;
        private XRTableRow xrTableRow4;
        private TopMarginBand topMarginBand1;
        private BottomMarginBand bottomMarginBand1;
        private Container components;
        /// <summary> 
        /// Clean up any resources being used.
        /// </summary>
        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                if (this.components != null)
                {
                    this.components.Dispose();
                }
                if ((this.bandDetail != null) && (this.bandDetail.Controls != null))
                {
                    foreach (object obj2 in this.bandDetail.Controls)
                    {
                        Subreport subreport = obj2 as Subreport;
                        if ((subreport != null) && (subreport.ReportSource != null))
                        {
                            subreport.ReportSource.Dispose();
                            subreport.ReportSource = null;
                        }
                    }
                }
            }
            base.Dispose(disposing);
        }

        #region Component Designer generated code

        /// <summary> 
        /// Required method for Designer support - do not modify 
        /// the contents of this method with the code editor.
        /// </summary>        
        private void InitializeComponent()
        {
            this.bandDetail = new DevExpress.XtraReports.UI.DetailBand();
            this.PageHeader = new DevExpress.XtraReports.UI.PageHeaderBand();
            this.lblDemoVersion = new DevExpress.XtraReports.UI.XRLabel();
            this.lblPeriode = new DevExpress.XtraReports.UI.XRLabel();
            this.pageInfoDate = new DevExpress.XtraReports.UI.XRPageInfo();
            this.xrTable1 = new DevExpress.XtraReports.UI.XRTable();
            this.xrTableRow3 = new DevExpress.XtraReports.UI.XRTableRow();
            this.cellBericht = new DevExpress.XtraReports.UI.XRTableCell();
            this.cellTitel = new DevExpress.XtraReports.UI.XRTableCell();
            this.xrTableRow1 = new DevExpress.XtraReports.UI.XRTableRow();
            this.cellCompanyLbl = new DevExpress.XtraReports.UI.XRTableCell();
            this.cellCompany = new DevExpress.XtraReports.UI.XRTableCell();
            this.xrTableRow2 = new DevExpress.XtraReports.UI.XRTableRow();
            this.cellProjectLbl = new DevExpress.XtraReports.UI.XRTableCell();
            this.cellProject = new DevExpress.XtraReports.UI.XRTableCell();
            this.xrTable2 = new DevExpress.XtraReports.UI.XRTable();
            this.xrTableRow4 = new DevExpress.XtraReports.UI.XRTableRow();
            this.cellFileName = new DevExpress.XtraReports.UI.XRTableCell();
            this.cellCreator = new DevExpress.XtraReports.UI.XRTableCell();
            this.xrTableCell7 = new DevExpress.XtraReports.UI.XRTableCell();
            this.xrPageInfo3 = new DevExpress.XtraReports.UI.XRPageInfo();
            this.PageFooter = new DevExpress.XtraReports.UI.PageFooterBand();
            this.topMarginBand1 = new DevExpress.XtraReports.UI.TopMarginBand();
            this.bottomMarginBand1 = new DevExpress.XtraReports.UI.BottomMarginBand();
            ((System.ComponentModel.ISupportInitialize)(this.xrTable1)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this.xrTable2)).BeginInit();
            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
            // 
            // bandDetail
            // 
            this.bandDetail.BackColor = System.Drawing.Color.Transparent;
            this.bandDetail.ForeColor = System.Drawing.SystemColors.ControlText;
            this.bandDetail.HeightF = 0F;
            this.bandDetail.Name = "bandDetail";
            this.bandDetail.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
            this.bandDetail.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            // 
            // PageHeader
            // 
            this.PageHeader.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
            this.lblDemoVersion,
            this.lblPeriode,
            this.pageInfoDate,
            this.xrTable1});
            this.PageHeader.HeightF = 104F;
            this.PageHeader.Name = "PageHeader";
            this.PageHeader.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
            this.PageHeader.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            // 
            // lblDemoVersion
            // 
            this.lblDemoVersion.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold);
            this.lblDemoVersion.LocationFloat = new DevExpress.Utils.PointFloat(0F, 0F);
            this.lblDemoVersion.Name = "lblDemoVersion";
            this.lblDemoVersion.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
            this.lblDemoVersion.SizeF = new System.Drawing.SizeF(300F, 20F);
            this.lblDemoVersion.Text = "SwissCreate Business Plan Writer abc";
            this.lblDemoVersion.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
            // 
            // lblPeriode
            // 
            this.lblPeriode.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.lblPeriode.LocationFloat = new DevExpress.Utils.PointFloat(0F, 84F);
            this.lblPeriode.Multiline = true;
            this.lblPeriode.Name = "lblPeriode";
            this.lblPeriode.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
            this.lblPeriode.SizeF = new System.Drawing.SizeF(627F, 20F);
            this.lblPeriode.Text = "Periode 2003-2005";
            this.lblPeriode.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
            // 
            // pageInfoDate
            // 
            this.pageInfoDate.BackColor = System.Drawing.Color.Transparent;
            this.pageInfoDate.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(43)))), ((int)(((byte)(99)))), ((int)(((byte)(183)))));
            this.pageInfoDate.Borders = DevExpress.XtraPrinting.BorderSide.None;
            this.pageInfoDate.BorderWidth = 1;
            this.pageInfoDate.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.pageInfoDate.ForeColor = System.Drawing.SystemColors.ControlText;
            this.pageInfoDate.Format = "{0:dd/MM/yyyy}";
            this.pageInfoDate.LocationFloat = new DevExpress.Utils.PointFloat(427F, 0F);
            this.pageInfoDate.Name = "pageInfoDate";
            this.pageInfoDate.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
            this.pageInfoDate.PageInfo = DevExpress.XtraPrinting.PageInfo.DateTime;
            this.pageInfoDate.SizeF = new System.Drawing.SizeF(200F, 20F);
            this.pageInfoDate.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
            // 
            // xrTable1
            // 
            this.xrTable1.BackColor = System.Drawing.Color.Transparent;
            this.xrTable1.Font = new System.Drawing.Font("Arial", 12F);
            this.xrTable1.LocationFloat = new DevExpress.Utils.PointFloat(0F, 20F);
            this.xrTable1.Name = "xrTable1";
            this.xrTable1.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 96F);
            this.xrTable1.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] {
            this.xrTableRow3,
            this.xrTableRow1,
            this.xrTableRow2});
            this.xrTable1.SizeF = new System.Drawing.SizeF(627F, 64F);
            this.xrTable1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            // 
            // xrTableRow3
            // 
            this.xrTableRow3.Cells.AddRange(new DevExpress.XtraReports.UI.XRTableCell[] {
            this.cellBericht,
            this.cellTitel});
            this.xrTableRow3.Name = "xrTableRow3";
            this.xrTableRow3.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 96F);
            this.xrTableRow3.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            this.xrTableRow3.Weight = 0.375;
            // 
            // cellBericht
            // 
            this.cellBericht.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(160)))), ((int)(((byte)(126)))), ((int)(((byte)(126)))));
            this.cellBericht.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(160)))), ((int)(((byte)(126)))), ((int)(((byte)(126)))));
            this.cellBericht.Borders = DevExpress.XtraPrinting.BorderSide.None;
            this.cellBericht.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Bold);
            this.cellBericht.ForeColor = System.Drawing.Color.White;
            this.cellBericht.Name = "cellBericht";
            this.cellBericht.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
            this.cellBericht.Text = "BERICHT";
            this.cellBericht.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            this.cellBericht.Weight = 0.23923444976076555;
            // 
            // cellTitel
            // 
            this.cellTitel.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0xE2)))), ((int)(((byte)(0xE2)))), ((int)(((byte)(0xE2)))));
            this.cellTitel.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(160)))), ((int)(((byte)(126)))), ((int)(((byte)(126)))));
            this.cellTitel.Borders = DevExpress.XtraPrinting.BorderSide.None;
            this.cellTitel.Font = new System.Drawing.Font("Verdana", 12.75F, System.Drawing.FontStyle.Bold);
            this.cellTitel.ForeColor = System.Drawing.Color.Black;
            this.cellTitel.Name = "cellTitel";
            this.cellTitel.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
            this.cellTitel.Text = "Rahmendaten";
            this.cellTitel.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
            this.cellTitel.Weight = 0.76076555023923442;
            // 
            // xrTableRow1
            // 
            this.xrTableRow1.BackColor = System.Drawing.Color.FromArgb(((int)(((byte)(0)))), ((int)(((byte)(0)))), ((int)(((byte)(192)))));
            this.xrTableRow1.Cells.AddRange(new DevExpress.XtraReports.UI.XRTableCell[] {
            this.cellCompanyLbl,
            this.cellCompany});
            this.xrTableRow1.Name = "xrTableRow1";
            this.xrTableRow1.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 96F);
            this.xrTableRow1.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            this.xrTableRow1.Weight = 0.3125;
            // 
            // cellCompanyLbl
            // 
            this.cellCompanyLbl.BackColor = System.Drawing.Color.Transparent;
            this.cellCompanyLbl.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(160)))), ((int)(((byte)(126)))), ((int)(((byte)(126)))));
            this.cellCompanyLbl.Borders = DevExpress.XtraPrinting.BorderSide.None;
            this.cellCompanyLbl.BorderWidth = 1;
            this.cellCompanyLbl.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cellCompanyLbl.ForeColor = System.Drawing.SystemColors.ControlText;
            this.cellCompanyLbl.Name = "cellCompanyLbl";
            this.cellCompanyLbl.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
            this.cellCompanyLbl.Text = "Company:";
            this.cellCompanyLbl.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
            this.cellCompanyLbl.Weight = 0.23923444976076555;
            // 
            // cellCompany
            // 
            this.cellCompany.BackColor = System.Drawing.Color.Transparent;
            this.cellCompany.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(160)))), ((int)(((byte)(126)))), ((int)(((byte)(126)))));
            this.cellCompany.Borders = DevExpress.XtraPrinting.BorderSide.None;
            this.cellCompany.BorderWidth = 1;
            this.cellCompany.Font = new System.Drawing.Font("Verdana", 9.75F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cellCompany.ForeColor = System.Drawing.SystemColors.ControlText;
            this.cellCompany.Multiline = true;
            this.cellCompany.Name = "cellCompany";
            this.cellCompany.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
            this.cellCompany.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
            this.cellCompany.Weight = 0.76076555023923442;
            // 
            // xrTableRow2
            // 
            this.xrTableRow2.Borders = DevExpress.XtraPrinting.BorderSide.None;
            this.xrTableRow2.Cells.AddRange(new DevExpress.XtraReports.UI.XRTableCell[] {
            this.cellProjectLbl,
            this.cellProject});
            this.xrTableRow2.Name = "xrTableRow2";
            this.xrTableRow2.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 96F);
            this.xrTableRow2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            this.xrTableRow2.Weight = 0.3125;
            // 
            // cellProjectLbl
            // 
            this.cellProjectLbl.BackColor = System.Drawing.Color.Transparent;
            this.cellProjectLbl.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(160)))), ((int)(((byte)(126)))), ((int)(((byte)(126)))));
            this.cellProjectLbl.Borders = DevExpress.XtraPrinting.BorderSide.None;
            this.cellProjectLbl.BorderWidth = 1;
            this.cellProjectLbl.Font = new System.Drawing.Font("Arial", 9.75F, System.Drawing.FontStyle.Bold);
            this.cellProjectLbl.ForeColor = System.Drawing.SystemColors.ControlText;
            this.cellProjectLbl.Name = "cellProjectLbl";
            this.cellProjectLbl.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
            this.cellProjectLbl.Text = "Project:";
            this.cellProjectLbl.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
            this.cellProjectLbl.Weight = 0.23923444976076555;
            // 
            // cellProject
            // 
            this.cellProject.BackColor = System.Drawing.Color.Transparent;
            this.cellProject.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(160)))), ((int)(((byte)(126)))), ((int)(((byte)(126)))));
            this.cellProject.Borders = DevExpress.XtraPrinting.BorderSide.None;
            this.cellProject.BorderWidth = 1;
            this.cellProject.Font = new System.Drawing.Font("Verdana", 9.75F);
            this.cellProject.ForeColor = System.Drawing.SystemColors.ControlText;
            this.cellProject.Multiline = true;
            this.cellProject.Name = "cellProject";
            this.cellProject.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
            this.cellProject.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            this.cellProject.Weight = 0.76076555023923442;
            // 
            // xrTable2
            // 
            this.xrTable2.LocationFloat = new DevExpress.Utils.PointFloat(0F, 5F);
            this.xrTable2.Name = "xrTable2";
            this.xrTable2.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 96F);
            this.xrTable2.Rows.AddRange(new DevExpress.XtraReports.UI.XRTableRow[] {
            this.xrTableRow4});
            this.xrTable2.SizeF = new System.Drawing.SizeF(627F, 25F);
            this.xrTable2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            // 
            // xrTableRow4
            // 
            this.xrTableRow4.Cells.AddRange(new DevExpress.XtraReports.UI.XRTableCell[] {
            this.cellFileName,
            this.cellCreator,
            this.xrTableCell7});
            this.xrTableRow4.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.xrTableRow4.Name = "xrTableRow4";
            this.xrTableRow4.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 96F);
            this.xrTableRow4.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            this.xrTableRow4.Weight = 1;
            // 
            // cellFileName
            // 
            this.cellFileName.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(160)))), ((int)(((byte)(126)))), ((int)(((byte)(126)))));
            this.cellFileName.Borders = DevExpress.XtraPrinting.BorderSide.None;
            this.cellFileName.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cellFileName.Multiline = true;
            this.cellFileName.Name = "cellFileName";
            this.cellFileName.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
            this.cellFileName.Text = "cellFileName";
            this.cellFileName.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
            this.cellFileName.Weight = 0.44178628389154706;
            // 
            // cellCreator
            // 
            this.cellCreator.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(160)))), ((int)(((byte)(126)))), ((int)(((byte)(126)))));
            this.cellCreator.Borders = DevExpress.XtraPrinting.BorderSide.None;
            this.cellCreator.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.cellCreator.Multiline = true;
            this.cellCreator.Name = "cellCreator";
            this.cellCreator.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
            this.cellCreator.Text = "cellCreator";
            this.cellCreator.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleLeft;
            this.cellCreator.Weight = 0.46411483253588515;
            // 
            // xrTableCell7
            // 
            this.xrTableCell7.BorderColor = System.Drawing.Color.FromArgb(((int)(((byte)(160)))), ((int)(((byte)(126)))), ((int)(((byte)(126)))));
            this.xrTableCell7.Borders = DevExpress.XtraPrinting.BorderSide.None;
            this.xrTableCell7.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
            this.xrPageInfo3});
            this.xrTableCell7.Name = "xrTableCell7";
            this.xrTableCell7.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
            this.xrTableCell7.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            this.xrTableCell7.Weight = 0.094098883572567779;
            // 
            // xrPageInfo3
            // 
            this.xrPageInfo3.BorderColor = System.Drawing.Color.Transparent;
            this.xrPageInfo3.Font = new System.Drawing.Font("Arial", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
            this.xrPageInfo3.LocationFloat = new DevExpress.Utils.PointFloat(0F, 5F);
            this.xrPageInfo3.Name = "xrPageInfo3";
            this.xrPageInfo3.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
            this.xrPageInfo3.SizeF = new System.Drawing.SizeF(58F, 24F);
            this.xrPageInfo3.TextAlignment = DevExpress.XtraPrinting.TextAlignment.MiddleRight;
            // 
            // PageFooter
            // 
            this.PageFooter.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
            this.xrTable2});
            this.PageFooter.HeightF = 30F;
            this.PageFooter.Name = "PageFooter";
            this.PageFooter.Padding = new DevExpress.XtraPrinting.PaddingInfo(0, 0, 0, 0, 100F);
            this.PageFooter.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopLeft;
            // 
            // topMarginBand1
            // 
            this.topMarginBand1.Name = "topMarginBand1";
            // 
            // bottomMarginBand1
            // 
            this.bottomMarginBand1.Name = "bottomMarginBand1";
            // 
            // ReportTemplate
            // 
            this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
            this.bandDetail,
            this.PageHeader,
            this.PageFooter,
            this.topMarginBand1,
            this.bottomMarginBand1});
            this.PageHeight = 1169;
            this.PageWidth = 827;
            this.PaperKind = System.Drawing.Printing.PaperKind.A4;
            this.Version = "10.1";
            ((System.ComponentModel.ISupportInitialize)(this.xrTable1)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this.xrTable2)).EndInit();
            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();

        }

        #endregion
        public ReportTemplate()
        {
            this.m_sTitle = "Titel";
            string rsErr = "";
            try
            {
                this.InitializeComponent();                
                this.SetHeaderFooter(ref rsErr);
            }
            catch (Exception exception)
            {
                Log.LogException(exception);
            }
        }

        public int AddNewSubReport(object oChartSubReport, int iNumberOfElements, bool bHasInterpretation)
        {
            int num = 0;
            int showEmptyCharts = VMConfig.Intance.Charts.ShowEmptyCharts;
            try
            {
                XtraReport report = oChartSubReport as XtraReport;
                if ((report != null) && ChartReportIsToAdd(iNumberOfElements, bHasInterpretation))
                {
                    this.AddSubReport2().ReportSource = report;
                    num = 1;
                }
            }
            catch (Exception exception)
            {
                Log.LogException(exception);
            }
            return num;
        }
        public DevExpress.XtraReports.UI.XRSubreport AddSubReport2()
        {
            DevExpress.XtraReports.UI.XRSubreport xrSubreport1 =null;
            try
            {
                xrSubreport1 = new DevExpress.XtraReports.UI.XRSubreport()
                {
                    Location = new Point(0, 0)
                };
                xrSubreport1.SizeF = new System.Drawing.SizeF(100F, 23F);
                this.bandDetail.Controls.Add(xrSubreport1);
                this.bandDetail.BackColor = Color.Red;
            }
            catch (Exception exception)
            {
                Log.LogException(exception);
            }
            return xrSubreport1;
        }
        public Subreport AddSubReport()
        {
            Subreport child = null;
            try
            {
                child = new Subreport
                {
                    Location = new Point(0, 0),
                     SizeF = new System.Drawing.SizeF(100F, 23F)
                };
                this.bandDetail.Controls.Add(child);
            }
            catch (Exception exception)
            {
                Log.LogException(exception);
            }
            return child;
        }

        public static bool ChartReportIsToAdd(int iNumberOfElements, bool bHasInterpretation)
        {
            bool flag = true;
            int showEmptyCharts = VMConfig.Intance.Charts.ShowEmptyCharts;
            if (iNumberOfElements == 0)
            {
                switch (showEmptyCharts)
                {
                    case 0:
                        return false;

                    case 1:
                        if (!bHasInterpretation)
                        {
                            flag = false;
                        }
                        return flag;
                }
            }
            return flag;
        }

        public static void CustomizeUI(XtraReport oXtraReport)
        {
            oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.Watermark, CommandVisibility.None);
        }

        

        public static int GetFactorTypeGroupIndex(FactorType eFactorType)
        {
            int num = 0;
            try
            {
                FactorType type = eFactorType;
                if (type != FactorType.HK)
                {
                    if (type == FactorType.SK)
                    {
                        return 0x10;
                    }
                    if (type == FactorType.BK)
                    {
                        return 0x20;
                    }
                }
                else
                {
                    return 8;
                }
                num = 0;
            }
            catch (Exception exception)
            {
                Log.LogException(exception);
            }
            return num;
        }     

        public static string GetInterpretationString(string sInterpretation)
        {
            return sInterpretation;
        }

        public static void GetMessageString(System.Collections.Specialized.StringCollection aMessages)
        {
            string str = string.Empty;
            if ((aMessages != null) && VMConfig.Intance.Charts.ShowMissingChartsWarning)
            {
                foreach (string str2 in aMessages)
                {
                    str = str + "\n" + str2;
                }
                if (str != string.Empty)
                {
                    //MessageBox.Show("Folgende Bestandteile werden aufgrund fehlender Daten\nnicht dargestellt: \n" + str + ".", "Reports", MessageBoxButtons.OK, MessageBoxIcon.Asterisk);
                }
            }
        }

        public static PeriodList GetTimeLinePeriods(ProjectData oWorkingProject, int iPeriodStartIndex, int iPeriodEndIndex)
        {
            PeriodList list = new PeriodList();
            //todo
            //Period period = null;
            //try
            //{
            //    if ((iPeriodEndIndex > (oWorkingProject.Periods.Count - 1)) || (iPeriodEndIndex < 0))
            //    {
            //        iPeriodEndIndex = oWorkingProject.Periods.Count - 1;
            //    }
            //    if ((iPeriodStartIndex > iPeriodEndIndex) || (iPeriodStartIndex < 0))
            //    {
            //        if ((iPeriodEndIndex - iPeriodStartIndex) > 5)
            //        {
            //            iPeriodStartIndex = iPeriodEndIndex - 5;
            //        }
            //        else
            //        {
            //            iPeriodStartIndex = iPeriodEndIndex;
            //        }
            //    }
            //    for (int i = iPeriodStartIndex; i <= iPeriodEndIndex; i++)
            //    {
            //        if (i >= 0)
            //        {
            //            period = (Period)oWorkingProject.Periods[i];
            //            list.Add(period);
            //        }
            //    }
            //    if (oWorkingProject.Periods.Count > 0)
            //    {
            //        period = (Period)oWorkingProject.Periods[oWorkingProject.Periods.Count - 1];
            //        list.Add(period);
            //    }
            //}
            //catch (Exception exception)
            //{
            //    Log.LogException(exception);
            //}
            return list;
        }

       

        private bool SetHeaderFooter(ref string rsErr)
        {
            bool flag = true;
            try
            {
                base.Name = this.Title;
                this.cellCompany.Text = ProjectData.Intance.CompanyName;
                this.cellProject.Text = ProjectData.Intance.Name;
                //Todo
                //if (RootData.Intance.CurrentPeriod != null)
                //{
                //    this.lblPeriode.Text = string.Format("{0} ({1} - {2})", RootData.Intance.CurrentPeriod.Name, RootData.Intance.CurrentPeriod.StartDate.ToShortDateString(), RootData.Intance.CurrentPeriod.EndDate.ToShortDateString());
                //}
                this.cellFileName.Text = "FileName: " + ProjectData.Intance.FileName;
                this.cellCreator.Text = "Creator: " + ProjectData.Intance.Author;
            }
            catch (Exception exception)
            {
                flag = false;
                rsErr = "Fehler in ReportTemplate.InitReport: " + exception.Message;
                Log.LogException(exception);
            }
            return flag;
        }

        public static void ShowExportFilters(XtraReport oXtraReport)
        {
            try
            {
                if (s_bExportCVS)
                {
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.ExportCsv, CommandVisibility.All);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendCsv, CommandVisibility.All);
                }
                else
                {
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.ExportCsv, CommandVisibility.None);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendCsv, CommandVisibility.None);
                }
                if (s_bExportMHT)
                {
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.ExportMht, CommandVisibility.All);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendMht, CommandVisibility.All);
                }
                else
                {
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.ExportMht, CommandVisibility.None);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendMht, CommandVisibility.None);
                }
                if (s_bExportTXT)
                {
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.ExportTxt, CommandVisibility.All);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendTxt, CommandVisibility.All);
                }
                else
                {
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.ExportTxt, CommandVisibility.None);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendTxt, CommandVisibility.None);
                }
                if (s_bExportXLS)
                {
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.ExportXls, CommandVisibility.All);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendXls, CommandVisibility.All);
                }
                else
                {
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.ExportXls, CommandVisibility.None);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendXls, CommandVisibility.None);
                }
                if (s_bExportHTM)
                {
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.ExportHtm, CommandVisibility.All);
                }
                else
                {
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.ExportHtm, CommandVisibility.None);
                }
                if (s_bExportRTF)
                {
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.ExportRtf, CommandVisibility.All);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendRtf, CommandVisibility.All);
                }
                else
                {
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.ExportRtf, CommandVisibility.None);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendRtf, CommandVisibility.None);
                }
                if (s_bExportPDF)
                {
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.ExportPdf, CommandVisibility.All);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendPdf, CommandVisibility.All);
                }
                else
                {
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.ExportPdf, CommandVisibility.None);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendPdf, CommandVisibility.None);
                }
                if (!s_bShowSendAsMailExportOption)
                {
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendCsv, CommandVisibility.None);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendFile, CommandVisibility.None);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendGraphic, CommandVisibility.None);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendMht, CommandVisibility.None);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendPdf, CommandVisibility.None);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendRtf, CommandVisibility.None);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendTxt, CommandVisibility.None);
                    oXtraReport.PrintingSystem.SetCommandVisibility(PrintingSystemCommand.SendXls, CommandVisibility.None);
                }
            }
            catch (Exception exception)
            {
                Log.LogException(exception);
            }
        }

        public static void ShowReportPreview(object oReportObject)
        {
            try
            {
                XtraReport report = oReportObject as XtraReport;
                if (report != null)
                {
                    if (VMConfig.Intance.Charts.AllowMultiplePreviews)
                    {
                        report.CreateDocument();
                        report.ShowPreview();
                        if (VMConfig.Intance.Charts.MaximiseReports)
                        {
                            //report.PrintingSystem.PreviewForm.WindowState = FormWindowState.Maximized;
                        }
                        else
                        {
                            //report.PrintingSystem.PreviewForm.WindowState = FormWindowState.Normal;
                        }
                    }
                    else
                    {
                        report.ShowPreviewDialog();
                        report.ClosePreview();
                        report.Dispose();
                        report = null;
                    }
                }
            }
            catch (IOException exception)
            {
                MessageBox.Show("Beim Speichern ist folgender Fehler aufgetreten: \n\n " + exception.Message, "Reports", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Log.LogException(exception);
            }
            catch (Exception exception2)
            {
                MessageBox.Show("Bei der Druckvorschau ist folgender Fehler aufgetreten: \n\n " + exception2.Message, "Reports", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                Log.LogException(exception2);
            }
        }

        public static bool StringHasValue(string sInput)
        {
            bool flag = true;
            return (((sInput != null) && !(sInput == string.Empty)) && flag);
        }

        public bool LandscapeOrientation
        {
            get
            {
                return this.m_bLandscapeOrientation;
            }
            set
            {
                this.m_bLandscapeOrientation = value;
                base.Landscape = true;
                base.Landscape = this.m_bLandscapeOrientation;
                int num = s_iLandscapePageWidth;
                this.xrTable1.Width = num;
                this.xrTable2.Width = num;
                this.cellBericht.Width = s_iLandscapeBerichtWidth;
                this.cellCompanyLbl.Width = s_iLandscapeBerichtWidth;
                this.cellProjectLbl.Width = s_iLandscapeBerichtWidth;
                this.lblPeriode.Width = num;
                this.pageInfoDate.Width = num;
            }
        }

        public string Title
        {
            get
            {
                return this.m_sTitle;
            }
            set
            {
                this.m_sTitle = value;
                this.cellTitel.Text = this.m_sTitle;
            }
        }        
    }
}
